<template>
    <div class="header">
        <div class="logo">
            <h1>实验项目安全风险评估系统</h1>
            <p>Experimental project safety risk assessment system</p>
        </div>
        <div class="userInfo">
            <i class="el-icon-s-custom"></i>
            <span class="marginR-1">{{ userInfo.userName }}</span>
            <span class="marginR-1">{{ userInfo.companyName }}</span>
            <span class="quit-btn" @click="quitClick">退出</span>
            <!-- <el-dropdown @command="handleCommand" trigger="click">
                <span class="el-dropdown-link">
                    个人中心<i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item command="changePsd">密码修改</el-dropdown-item>
                    <el-dropdown-item command="exit">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown> -->
        </div>
    </div>
</template>
<script>
import {request} from "@/assets/js/utils/request";
export default{
    name: 'headerBar',
    data() {
        return {
            userInfo: ''
        }
    },
    created() {
        let str = sessionStorage.getItem('userInfo')
        this.userInfo = JSON.parse(str)
    },
    methods: {
        quitClick() {
            request({
                url: '/jaccountLogout.jsp',
                method: 'post'
            }).then(res => {
                if(res.code == 200) {
                    window.location = res.data
                    sessionStorage.removeItem('token')
                    sessionStorage.removeItem('userInfo')
                    sessionStorage.removeItem('rightCodes')
                } else {
                    this.$message.error(res.msg);
                }
            })
        },
        // handleCommand(command) {
        //     if(command == 'changePsd') {
        //         this.$router.push('/updatePassword')
        //     }else {
        //         this.$router.push('/login')
        //         localStorage.removeItem('token')
        //         localStorage.removeItem('userInfo')
        //         localStorage.removeItem('rightCodes')
        //     }
        // }
    }
}
</script>
<style lang="less" scoped>
.header{
    width: 88%;
    display: flex;
    justify-content: space-between;
    .logo{
        padding-top: 20px;
        line-height: 25px;
        h1{
            font-size: 28px;
            font-weight: 600;
            color: #595959;
        }
        p{
            font-size: 14px;
            color:#595959;
        }
    }
    /deep/.userInfo{
        color: #595959;
        line-height: 80px;
        .quit-btn{
            cursor: pointer;
        }
        // .el-dropdown{
        //     cursor: pointer;
        //     color: #595959;
        // }
    }
}
</style>